package megrez.bussiness.schedule.repository;

import java.util.Set;

import org.springframework.data.jpa.domain.Specification;

import lombok.experimental.UtilityClass;
import megrez.bussiness.schedule.entity.Job;
import megrez.bussiness.schedule.entity.JobLog;
import megrez.bussiness.schedule.entity.JobLog.Level;

/**
 * 任务日志查询条件
 * 
 * @author Lucky Yang
 * @since 0.0.1
 */
@UtilityClass
public class JobLogSpecification {
    public Specification<JobLog> levelIn(Set<Level> levels) {
        return (root, query, builder) -> builder.in(root.get("levels")).value(levels);
    }

    public Specification<JobLog> jobEqual(Job job) {
        return (root, query, builder) -> builder.equal(root.get("job"), job);
    }
}